{extend name='main'}

{block name="button"}

{if auth("admin/database/addBackups")}
<button data-load='{:url("addBackups")}'  class='layui-btn layui-btn-sm layui-btn-primary'>新增备份</button>
{/if}

{if auth("admin/database/delBackups")}
<button data-action='{:url("delBackups")}' data-rule="id#{key}" class='layui-btn layui-btn-sm layui-btn-primary'>删除备份</button>{/if}

{/block}

{block name="content"}
<div class="think-box-shadow">
    {include file='database/index_auto'}
    <table class="layui-table margin-top-10" lay-skin="line">
        {notempty name='list'}
        <thead>
        <tr>
            <th class='list-table-check-td think-checkbox'>
                <input data-auto-none data-check-target='.list-check-box' type='checkbox'>
            </th>
            <th class='text-center nowrap'>序号</th>
            <th class='text-center nowrap'>备份名称</th>
            <th class='text-center nowrap'>备份时间</th>
            <th class='text-center nowrap'>备份大小</th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        {foreach $list as $key=>$vo}
        <tr data-dbclick>
            <td class='list-table-check-td think-checkbox'>
                <input class="list-check-box" value='{$vo.time}' type='checkbox'>
            </td>
            <td class="text-center nowrap">
                {$leng--}
            </td>
            <td class='text-center nowrap'>
                <p class="color-text">{:date(('Ymd-His'),$vo['time']).'-'.$vo['part'].'.sql'}</p>
            </td>
            <td class='text-center nowrap'>
                <p class="color-text">{:date('Y-m-d H:i:s',$vo['time'])}</p>
            </td>
            <td class='text-center nowrap'>
                {:ceil($vo['size']/1024)}kb
            </td>
            <td class='text-center nowrap'>
                {if auth("admin/database/restoreBackups")}
                <a data-dbclick class="layui-btn layui-btn-sm layui-btn-danger" data-value="{$vo['time']}" data-confirm="确定要还原这个版本的数据吗？" data-action="{:url('restoreBackups')}?time={$vo['time']}"  data-csrf="{:systoken('admin/database/restoreBackups')}">还原</a>
                {/if}
                {if auth("admin/database/downloadBackups")}
                <a data-dbclick class="layui-btn layui-btn-sm" href="{:url('downloadBackups')}?time={$vo['time']}"  data-csrf="{:systoken('admin/database/downloadBackups')}">下载</a>
                {/if}
            </td>
        </tr>
        {/foreach}
        </tbody>
        {/notempty}
    </table>

    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}

</div>

{/block}
